// app.js
var QQMapWX = require('/utils/qqmap-wx-jssdk.min.js');
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
  // 请求完新版本信息的回调
})
updateManager.onUpdateReady(function () {
  updateManager.applyUpdate()

})

updateManager.onUpdateFailed(function () {
  // 新版本下载失败
})
App({

   

  onLaunch: function () {

    var that = this;

　　　　　//1.2实例化腾讯地图API核心类
        that.globalData.qqmapsdk = new QQMapWX({     
            key: 'K2CBZ-WL7KU-23KVC-BILQJ-LWCIK-SKFLS'
        }); 
　　　　　//1.3wx.getLocation方法获取当前位置坐标。
        wx.getLocation({                   
            altitude:false,
            success: function (res) {
                var latitude = res.latitude;
                var longitude = res.longitude;

                that.globalData.location={

                    latitude: latitude,
                    longitude: longitude
                }
               
            }
        });

    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    this.globalData.sysinfo = wx.getSystemInfoSync()
    var that = this;
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
          that.globalData.statusBarHeight = res.statusBarHeight*1+46*1
          that.globalData.statusBarHeight1 = res.statusBarHeight
          console.log(res.statusBarHeight, 'statusBarHeight')
      }
      
    })
    //获取用户本地是否是第一次进入新版本
    var versions = wx.getStorageSync('versions');
    //console.log('versions:' + versions);
    //判断是不是需要授权
    if (versions == '1'){
      // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
      wx.getUserInfo({
        success: function (res) {
          that.globalData.userInfo = res.userInfo
          //console.log(that.globalData.userInfo)
        },
        fail: function () {
          // wx.redirectTo({
          //   url: '../wurui_house/pages/login/index',
          // })
        }
      })
    }else{
      // 未授权, 跳转登录页面
      // wx.redirectTo({
      //   url: '../wurui_house/pages/login/index',
      // })
    }
    // 获取顶部栏信息
    wx.getSystemInfo({
      success: res => {
        //导航高度
        this.globalData.navHeight = res.statusBarHeight + 46;
      }, fail(err) {
        //console.log(err);
      }
    })
  },
  globalData: {
    yh_zt:"1",
    qs_tsid:"",
    hy_dz:"",
    hy_id:"",
    id_hy:"",
    shu_d:" ",
    store_id:"",
    dj:"",
    num:"",
    qy_id:"",
    qy_name:"",
    conten:"",
    areas_id:"",
    sf_zt:"",
    postData:"",
    url_l: 'https://beijingyada.ascetic.top/api/',
    userInfo: null,
    navHeight: 0,
    appid: "",
    token:"",
    check_type:"",
    openid:"",
    today_num:"",
    fl:"",
    appsecret: "",
    session_key:"",
    uid:"1",
    shq_id:"",
    gid:"",
    user_name:"",
    xz_sz:"",
    xz_sz1:"",
    qu_dz:"",
    song_dz:"",
    qu_did:"",
    song_did:"",
    qu_dz1:"",
    song_dz1:"",
    qu_did1:"",
    song_did1:"",
    key:"",
  screenWidth:wx.getSystemInfoSync().screenWidth,
  screenHeight:wx.getSystemInfoSync().screenHeight,
},
getModel: function () { //获取手机型号
  return this.globalData.sysinfo["model"]
},
getVersion: function () { //获取微信版本号
  return this.globalData.sysinfo["version"]
},
getSystem: function () { //获取操作系统版本
  return this.globalData.sysinfo["system"]
},
getPlatform: function () { //获取客户端平台
  return this.globalData.sysinfo["platform"]
},
getSDKVersion: function () { //获取客户端基础库版本
  return this.globalData.sysinfo["SDKVersion"]
},
BLEInformation:{
  platform: "",
  deviceId:"",
  writeCharaterId: "",    
  writeServiceId: "",
  notifyCharaterId: "",
  notifyServiceId: "",
  readCharaterId: "",
  readServiceId: "",
},
  getLocationInfo: function (cb) {
    var that = this;
    if (this.globalData.locationInfo) {
      cb(this.globalData.locationInfo)
    } else {
      wx.getLocation({
        type: 'gcj02', // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
        success: function (res) {
          that.globalData.locationInfo = res;
          cb(that.globalData.locationInfo)
        },
        fail: function () {
          // fail
        },
        complete: function () {
          // complete
        }
      })
    }
  },
  util: require('utils/util.js'),

})



      // {
      //   "pagePath": "static/gouwu/gouwu",
      //   "iconPath": "image/icon@_7.png",
      //   "selectedIconPath": "image/icon@_8.png",
      //   "text": "购物车"
      // },